package com.lzs.bootsafety.business.oss.controller;

import com.github.pagehelper.PageInfo;
import com.lzs.bootsafety.business.oss.entity.SysConfig;
import com.lzs.bootsafety.business.oss.service.SysConfigService;
import com.lzs.bootsafety.common.base.controller.BaseController;
import com.lzs.bootsafety.common.util.Resu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 *  云存储配置
 *  @author  zhanshi Liu
 *  @date    2020/04/18
 *  @website www.jhmsona.cn
 *
 */
@RestController
@RequestMapping("/oss/config")
public class SysConfigController extends BaseController {
    @Autowired
    private SysConfigService sysConfigService;
    @GetMapping("/list")
    public Resu list(@RequestBody SysConfig sysConfig){
        PageInfo<SysConfig> pageInfo = sysConfigService.getConfigs(sysConfig);
        return Resu.page(pageInfo.getList(),pageInfo.getTotal(),200);
    }

    /**
     * 获取配置信息
     * @return
     */
    @GetMapping("/map")
    public Map<String, Object> getMap(){
        Map<String ,Object> data = sysConfigService.getConfigs();
        return data;
    }

    /**
     * 更新配置
     * @param map
     * @return
     */
    @PutMapping("/update")
    public Resu update(@RequestBody Map<String ,Object> map){
        int r = sysConfigService.updateConfings(map);
        return respudp(r);
    }
}
